using Godot;
using System;
using System.Collections.Generic;

public class BlockStruct
{
    public String Name;
    List<BlockPosition> blocks = new List<BlockPosition>();
    public BlockStruct()
    {

    }
    public void Spawn(BlockWorld world, int x, int y,int z)
    {
        foreach (BlockPosition bi in blocks)
        {
            world.SetBlock(new Vector3I(x + bi.x, y + bi.y,z), bi.material);
        }
    }
    public void SetBlock(int x, int y, BlockMaterial bm)
    {
        foreach (BlockPosition bi in blocks)
        {
            if (bi.x == x && bi.y == y)
            {
                return;
            }
        }
        blocks.Add(new BlockPosition(x, y, bm));
    }
    public void SetBlock(BlockMaterial bm, params Vector2[] locals)
    {
        foreach (Vector2 v in locals)
        {
            SetBlock((int)v.x, (int)v.y, bm);
        }
    }
    public void SetBlock(BlockMaterial bm, params int[] locals)
    {
        GD.Print(locals.Length);
        for (int i = 0; i < locals.Length; i += 2)
        {
            SetBlock(locals[i], locals[i + 1], bm);
        }
    }
}

public class BlockPosition
{
    public int x;
    public int y;
    public BlockMaterial material;
    public BlockPosition(int x, int y, BlockMaterial material)
    {
        this.x = x;
        this.y = y;
        this.material = material;
    }
}